//
// Created by tongj on 2024/1/13.
//

#ifndef BUFFER_ITERATOR_CUH_
#define BUFFER_ITERATOR_CUH_

template<typename T>
tbs::buffer::BufferIterator<T>::BufferIterator(tbs::buffer::Buffer *buffer, size_t index)
	:_buffer(buffer), _index(index) {

}

template<typename T>
tbs::structs::Iterator<T> &tbs::buffer::BufferIterator<T>::next() {
  ++_index;
  return *this;
}

template<typename T>
bool tbs::buffer::BufferIterator<T>::has_next() const {
  auto s = _buffer->len_t<T>();
  return _index < s;
}

template<typename T>
T &tbs::buffer::BufferIterator<T>::value() {
  return _buffer->seek<T>(_index);
}

template<typename T>
const void *tbs::buffer::BufferIterator<T>::source() const {
  return (void *)_buffer;
}

template<typename T>
const size_t tbs::buffer::BufferIterator<T>::index() const {
  return _index;
}

#endif //BUFFER_ITERATOR_CUH_
